package wsi.gui.resolve.model;

import java.io.File;

import javafx.beans.property.DoubleProperty;
import javafx.beans.property.IntegerProperty;
import javafx.beans.property.SimpleDoubleProperty;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;

import org.rygh.core.util.UIo;

import wsi.exp.exp5.JudgeFile;
import wsi.function.Function;

public class FunctionFileTuple {
	private final StringProperty fileName = new SimpleStringProperty(
			this, "fileName");
	private final IntegerProperty numberOfPairs = new SimpleIntegerProperty(
			this, "numberOfPairs");
	private final IntegerProperty numberOfJudgedPairs = new SimpleIntegerProperty(
			this, "numberOfJudgedPairs");
	private final DoubleProperty precision = new SimpleDoubleProperty(this,
			"precision");

	private final Function function;
	private final File xmlFile;
	private final File judgeFile;

	public FunctionFileTuple(Function function, File xmlFile, File judgeFile) {
		this.function = function;
		this.xmlFile = xmlFile;
		this.judgeFile = judgeFile;

		String fname = UIo.getFileNameWithoutExtension(xmlFile.getName());

		JudgeFile jfile = new JudgeFile(judgeFile);

		fileName.set(fname);
		numberOfPairs.set(jfile.size());
		numberOfJudgedPairs.set(jfile.getJudgedSize());
		precision.set(jfile.getPrecision());
	}

	public StringProperty fileNameProperty() {
		return fileName;
	}

	public Function getFunction() {
		return function;
	}

	public File getJudgeFile() {
		return judgeFile;
	}

	public File getXmlFile() {
		return xmlFile;
	}

	public IntegerProperty numberOfJudgedPairsProperty() {
		return numberOfJudgedPairs;
	}

	public IntegerProperty numberOfPairsProperty() {
		return numberOfPairs;
	}

	public DoubleProperty precisionProperty() {
		return precision;
	}
}
